package com.jzqf.android.alive.navi

import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.baidu.mapapi.map.MapView
import com.jzqf.android.alive.R


class NaviActivity : AppCompatActivity() {
    private val TAG = "NaviActivity"
    private val naviBtn: Button by lazy {
        findViewById(R.id.navi_btn)
    }
//    private val mapView: MapView by lazy {
//        findViewById(R.id.mapView)
//    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_navi)
        NaviManager.initSdk(
            applicationContext, InitNaviOptions(
                appIdTTS = "",
                appKeyTTS = "",
                secretKeyTTS = "",
                authSnTTS = "",
                success = { code, msg ->
                    Log.d(TAG, "initSdk success: $code $msg")
                },
                fail = { code, msg ->
                    Log.e(TAG, "initSdk fail: $code $msg")
                })
        )
    }

    override fun onStart() {
        super.onStart()
        naviBtn.setOnClickListener {
            NaviManager.routePlanToNavi(
                StartNaviOptions(
                    startLatitude = 34.74624571061107,
                    startLongitude = 113.77802678414837,
                    endLatitude = 34.7769247920972,
                    endLongitude = 113.70427036833328,
                    success = { code, msg ->
                        Log.d(TAG, "routePlanToNavi success: $code $msg")
                    },
                    fail = { code, msg ->
                        Log.e(TAG, "routePlanToNavi fail: $code $msg")
                        Toast.makeText(this@NaviActivity, msg, Toast.LENGTH_SHORT).show()
                    })
            )
        }
    }


}